﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class K8878
    {
        public K8878()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;

            InitializeComponent();
            SDSA = "K8878";
        }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            if(dwMain==null)
            { }
            dwKEY = dwMaster;
            try
            {
                if (dwMaster != null)
                {
                    KEY = dwKEY["KEY"].ToString();
                    DES = Helpers.Helper.ConvertGB2312To8859P1(dwMaster["DES"].ToString());
                    SDES = Helpers.Helper.ConvertGB2312To8859P1(dwMaster["SDES"].ToString());
                    if (TBMain.Columns.Contains("VALUE"))
                    {
                        VALUE = dwKEY["VALUE"].ToString();
                    }
                }
                else
                {

                    KEY = "0";
                    DES = "0";
                    SDES = "0";
                    VALUE = "000000";
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public override void LOADALL()
        {
            base.LOADALL();
            foreach (DataRow row in TBMain.Rows)
            {
                row["SDES"] = Helpers.Helper.Convert8859P1ToGB2312(row["SDES"].ToString().Trim());
                row["DES"] = Helpers.Helper.Convert8859P1ToGB2312(row["DES"].ToString().Trim());
            } 
        } 
    }
}
